﻿Imports System.Data.SqlClient
Public Class frmEmployeeEditter
    Public Sub clear()
        txtId.Clear()
        txtName.Clear()
        cboSex.Text = ""
        txtPhone.Clear()
        txtSalary.Clear()
    End Sub
    Private Sub frmEmployeeEditter_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        txtId.Visible = False
        If txtId.Text = "" Then
            btnsave.Text = "Save"
        Else
            btnsave.Text = "Update"
        End If
    End Sub

    Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click
        If btnsave.Text = "Save" Then
            cmd.ExecuteNonQuery("insert into tblemployee valeus (N'" & txtName.Text & "',N'" & cboSex.Text & "','" & txtPhone.Text & "','" & txtSalary.Text & "')")
        Else
            cmd.ExecuteNonQuery("update tblemployee set emp_name = N'" & txtName.Text & "',sex=N'" & cboSex.Text & "',phone='" & txtPhone.Text & "',salary= '" & txtSalary.Text & "' where emp_id='" & txtId.Text & "'")
        End If
        'frmEmployee.re_data()
        Me.Close()
        clear()
    End Sub

    Private Sub btnclose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnclose.Click
        Me.Close()
        clear()
    End Sub
End Class